<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%
String userid=(String)session.getAttribute("userid");

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
   <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="js/jquery-1.4.2.min.js" language="JavaScript"></script>
<style>

</style>

 <div style="border:2px solid #f0f0f0; height:35px; width:100%">
         <div style="width:10%; float:left; margin-top:5px">  <img   onclick="backs()" src="image/back.png"  height="25px;"  /></div>
	     <div  onclick="backss()" id="sqname" style="width:90%;  text-align:center ;float:left; font-size:20px;margin-top:4px">家庭医生签约 </div>	
  </div>
    <div  id="search"  style="background-color:#EAEAEA; height:2px; width:100%">   </div>
	<div id="aa">
	    <div  id="tx" style="margin-top:17px ; text-align:center ;  "><img    id="img"  height="80px;" width="80px;" /></div>
	     <div  id="name" style="margin-top:1px ; text-align:center ; font-size:20px;   "></div>
		 <div  id="zw" style=" color:#C0C0C0;margin-top:1px ; text-align:center ; font-size:17px;    "></div>
		 <div  id="jc" style=" color:#ABABAB;margin-top:1px ;  font-size:15px;    "></div>
	</div>
		<%if(userid==null){%>
	     <div  id="search"  style=" background-color:#EAEAEA;  height:30px; width:100% ; font-size:20px; text-align:center;
position:relative ;   ">
	 
     <p style="position:absolute;bottom:0px;padding:0px;margin:0px;">短信快捷登录</p>
	     </div>
		 
		 <form  id="form"   name="form"  method="post" action="reg.jsp">
		 <input name="opt" type="hidden"  value="yzmjx" />
		    <input   type="hidden"  name="doctor_id"   value="<%=request.getParameter("doctor_id")%>" />
			<input   type="hidden"  name="sqfwzx_id"   value="<%=request.getParameter("sqfwzx_id")%>" />
		   <div class="item-input">  
                        <input  style="width:100%;height:35px;"     name="tel" id="tel" maxlength="11"   onmouseout="jybutton()" placeholder="请输入你注册的手机号码"/></div>
		    <input  style="width:72%;height:35px;"       name="yzm"  id="yzm" maxlength="6"   onmouseout="jy()" placeholder="请输入接收到的验证码"/>      
			
			<input   style="height:35px; width:27%; font-size:12px; "   onclick="settime(this)"  id="button"  value="获取验证码" disabled  type="button" />	
			</form>
			<div style="margin-top:20px;">
			   <button  disabled="disabled"  id="logon" type="button" style="height:40px; font-size:20px;" class="btn btn-lg btn-success btn-block"               onClick="emit()">登录</button>
		
			 </div>
	<%} else {%> 
	       <div style="margin-top:70px;">
			    <button    id="logon" type="button" style="height:40px; font-size:20px;" class="btn btn-lg btn-success btn-block"                onClick="qy()">签约</button>
		
			 </div>
	<% }%>
<body>
</body>
</html>
<script>
   history.pushState(null, null, document.URL);
        window.addEventListener('popstate', function () {
            history.pushState(null, null, document.URL);
        });
var id='<%=request.getParameter("doctor_id")%>';
var sqfwzx_id='<%=request.getParameter("sqfwzx_id")%>';
var countdown=60; 
function settime(obj) { 
     if(countdown==60){
	     $.ajax( {    
            url:'/QueyServlet',
            type:'post',    
            cache:false,  
	       data:{tel:$('#tel').val(),opt:'send'},   
		    dataType:'json',   
           success:function(data) { 
		    if(data.result="ok")
		    alert("获取验证码成功");
	      },
	       error : function() 
	      {     
            alert("异常！");    
          }    
       });
    } 
    if (countdown == 0) { 	
        obj.removeAttribute("disabled");    
        obj.value="获取验证码"; 
        countdown = 60;
        return;
    } else { 
        obj.setAttribute("disabled", true); 
        obj.value="重新发送(" + countdown + ")"; 
        countdown--; 
		setTimeout(function() { 
    settime(obj) }
    ,1000) 
    } 

}
window.onload=function(){ 
id=id.substr(2,id.length-2);
var aj = $.ajax( {    
    url:'/QueyServlet',
    type:'get',    
    cache:false,  
	data:{op:'sqdoctor',doctor_id:id},
	  dataType:'json',   
    success:function(msg) { 
    if(msg.result=="ok"){
	 var data=msg.data;
	 document.getElementById("img").src=data[0].doctor_tx;
	$("#name").html(data[0].doctor_name);
	$("#zw").html(data[0].ks_name+"、"+data[0].zw_name);
	$("#jc").html("&nbsp;&nbsp;&nbsp;&nbsp;;&nbsp;&nbsp;"+data[0].doctor_describe);
	}
	
	},
	  error : function() 
	 {     
         alert("异常！");    
    }    
});
}
function backs(){
var id='<%=request.getParameter("sqfwzx_id")%>';
location="doctor.jsp?sqfwzx_id="+id+""; 
}
function jybutton(obj){
var tel=$('#tel').val();
if(tel.length==11){
$('#button').removeAttr("disabled");
$('#yzm').removeAttr("readonly");
}
else{
$('#button').attr('disabled',"true");
$('#yzm').attr('readonly',"true");
}
}

function jy(obj){
  var yzm=$('#yzm').val();
    if(yzm.length==6)
      $('#logon').removeAttr("disabled");
    else
     $('#logon').attr('disabled',"true");
}

function qy(){
  location="contract.jsp?doctor_id="+id+"&sqfwzx_id="+sqfwzx_id+""; 
}
function emit(){
var tel= document.getElementById("tel").value;
  $.ajax({
    type:"POST",
    url:"/UserServlet", //你的请求程序页面随便啦
    data:$('#form').serialize(),// 你的formid   
    async:false,//同步：意思是当有返回值以后才会进行后面的js程序。
	dataType:'json', 
    success:function(msg){
           if(msg.result=="error")
			 alert("验证码错误")
         else
		    location="contract.jsp?doctor_id="+id+"&tel="+tel+"&sqfwzx_id="+sqfwzx_id+""; 
    
   },
	  error : function() 
	 {     
         alert("异常！");    
    }  
	});
}
</script>